package com.retail.lottery.colalottery.job.order;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.retail.lottery.colalottery.constant.RedisConstant;
import com.retail.lottery.colalottery.entity.OrderCallback;
import com.retail.lottery.colalottery.enums.OrderCallbackStatusEnum;
import com.retail.lottery.colalottery.enums.OrderCallbackSyncStatusEnum;
import com.retail.lottery.colalottery.enums.PlatformEnum;
import com.retail.lottery.colalottery.service.OrderCallbackService;
import com.retail.lottery.colalottery.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.DependsOn;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

@Component
@Slf4j
@DependsOn("redisUtils")  // 确保beanB先初始化
public class OrderSyncJob {

    @Resource
    private OrderDetailDealStrategyService orderDetailDealStrategyService;

    @PostConstruct
    public void init() {
        executeSyncStatus();
    }

    @Scheduled(cron = "0/30 * * * * ?")
    private void executeSyncStatus() {
        orderDetailDealStrategyService.syncOrderStatus();
    }
}
